AngularJS டேபிள்கள்
ng-repeat டைரக்டிவ் டேபிள்களைக் காட்டுவதற்கு சிறந்தது.
உதவிக்குறிப்பு:
AngularJS டேபிள்களைக் காட்டுவது மிகவும் எளிதானது.
டேபிளில் தரவைக் காண்பித்தல்
Angular உடன் டேபிள்களைக் காண்பிப்பது மிகவும் எளிதானது:
AngularJS Example
<div ng-app="myApp" ng-controller="customersCtrl">
<table>
<tr ng-repeat="x in names">
<td>{{ x.Name }}</td>
<td>{{ x.Country }}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("customers.php")
.then(function (response) {$scope.names = response.data.records;});
});
</script>
CSS ஸ்டைலுடன் காண்பித்தல்
அழகாக இருக்க, பக்கத்தில் சில CSS ஐச் சேர்க்கவும்:
CSS Style
<style>
table, th , td {
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
}
table tr:nth-child(odd) {
background-color: #f1f1f1;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
</style>
orderBy வடிகட்டியுடன் காண்பித்தல்
டேபிளை வரிசைப்படுத்த, ஒரு orderBy வடிகட்டியைச் சேர்க்கவும்:
AngularJS Example
<table>
<tr ng-repeat="x in names | orderBy : 'Country'">
<td>{{ x.Name }}</td>
<td>{{ x.Country }}</td>
</tr>
</table>
uppercase வடிகட்டியுடன் காண்பித்தல்
பெரிய எழுத்துக்களைக் காட்ட, ஒரு uppercase வடிகட்டியைச் சேர்க்கவும்:
AngularJS Example
<table>
<tr ng-repeat="x in names">
<td>{{ x.Name }}</td>
<td>{{ x.Country | uppercase }}</td>
</tr>
</table>
டேபிள் இன்டெக்ஸைக் காண்பித்தல் ($index)
டேபிள் இன்டெக்ஸைக் காட்ட, $index உடன் ஒரு <td> ஐச் சேர்க்கவும்:
AngularJS Example
<table>
<tr ng-repeat="x in names">
<td>{{ $index + 1 }}</td>
<td>{{ x.Name }}</td>
<td>{{ x.Country }}</td>
</tr>
</table>
$even மற்றும் $odd ஐப் பயன்படுத்துதல்
AngularJS Example
<table>
<tr ng-repeat="x in names">
<td ng-if="$odd" style="background-color:#f1f1f1">{{ x.Name }}</td>
<td ng-if="$even">{{ x.Name }}</td>
<td ng-if="$odd" style="background-color:#f1f1f1">{{ x.Country }}</td>
<td ng-if="$even">{{ x.Country }}</td>
</tr>
</table>
முக்கிய குறிப்பு:
$even மற்றும் $odd ஆகியவை AngularJS இல் உள்ள சிறப்பு பண்புகள் ஆகும், அவை முறையே இரட்டை மற்றும் ஒற்றை வரிசைகளைக் கண்டறிய உதவுகின்றன.
பயிற்சிகள் மூலம் கற்றல்
டேபிளில் வரிசைகளை வரிசைப்படுத்த எந்த AngularJS வடிகட்டி பயன்படுத்தப்படுகிறது?
பயிற்சியைத் தொடங்கவும்:
மேலே உள்ள பயிற்சிகளை முயற்சிக்கவும். ஒவ்வொரு விருப்பத்தையும் கிளிக் செய்து சரியான பதிலைச் சரிபார்க்கவும்.
AngularJS டேபிள்களை மாஸ்டர் செய்ய இந்த கருத்துகள் முக்கியம்.